package com.mida.bms.report.controller;

import com.mida.bms.report.service.DocReportRequisitionRelationService;
import com.mida.bms.report.vo.*;
import com.mida.tool.common.result.ListResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 报告List
 */
@RestController
@RequestMapping("/docReportList")
@CrossOrigin
@Slf4j
public class DocReportListController {


    @Autowired
    private DocReportRequisitionRelationService docReportRequisitionRelationService;




    /**
     * 4、获取报告状态,和报告soid
     * @param requestSoid 申请单soid
     * @return 报告的流转状态，自身状态，报告soid
     */
    @GetMapping(value = "selectStautusByRequestSoid")
    @ResponseBody
    public ListResult<DocReportRequisitionRelationVo> selectStautusByRequestSoid(@RequestParam("requestSoid") Long requestSoid) {
        return docReportRequisitionRelationService.selectStautusByRequestSoid(requestSoid);
    }

    /**
     * 5。2、获取书写医生或审核医生标识
     * @param requestSoid 申请单soid
     * @return 书写医生/审核医生
     */
    @GetMapping(value = "selectDoctorByRequestSoid")
    public ListResult<DocReportRequisitionRelationVo> selectDoctorByRequestSoid(@RequestParam("requestSoid") Long requestSoid) {
        return docReportRequisitionRelationService.selectDoctorByRequestSoid(requestSoid);
    }

    /**
     * 5、分页查询待审核/已完成状态下报告list
     * @param vo reportProcessStatus -->16033111859003392 书写完成待审核  16033111879974912 审核完成
     * @return 申请单soid
     */
    @PostMapping(value = "/findReportPage",consumes = MediaType.APPLICATION_JSON_VALUE)
    public ListResult<PageResultVo<DocReportListVo>> findReportPage(@RequestBody DocReportListPageVo vo) {
        return docReportRequisitionRelationService.findReportPage(vo);
    }
    /**
     * 6、获取书写医生或审核医生标识、获取报告状态,和报告soid
     *
     * @param reportSearchRequest 申请单soid
     * @return 书写医生/审核医生/报告状态,和报告soid
     */
    @PostMapping(value = "selectDoctorAndStatus")
    public ListResult<DocReportRequisitionRelationVo> selectDoctorAndStatus(@RequestBody ReportSearchRequest reportSearchRequest) {
        ListResult result = new ListResult();
        try {
            return docReportRequisitionRelationService.selectDoctorAndStatus(reportSearchRequest);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            result.setStatus(HttpStatus.BAD_REQUEST.value());
            result.setMessage("获取医生和状态失败");
            return result;
        }
    }

    /**
     * 6、获取书写医生或审核医生标识、获取报告状态,和报告soid
     *
     * @param reportSearchVo 申请单soid
     * @return 书写医生/审核医生/报告状态,和报告soid
     */
    @PostMapping(value = "selectDoctorAndStatusList")
    public ListResult<List<DocReportRequisitionRelationVo>> selectDoctorAndStatusList(@RequestBody ReportSearchVo reportSearchVo) {
        ListResult result = new ListResult();
        try {
            return docReportRequisitionRelationService.selectDoctorAndStatusList(reportSearchVo);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            result.setStatus(HttpStatus.BAD_REQUEST.value());
            result.setMessage("获取医生和状态失败");
            return result;
        }
    }

}
